<template>
<div class="body" style="height:100vh"  v-loading.body="listLoading">
    <div>
      <NavBar
  title="2019学院排名"
/>
    </div>
     <el-table :data="list"  element-loading-text="Loading" border fit highlight-current-row>
       <el-table-column label="排名" align="center">
        <template slot-scope="scope">
          {{scope.$index+1}}
        </template>
      </el-table-column>
      <el-table-column align="center" label="院系">
        <template slot-scope="scope">
          {{scope.row.dep}}
        </template>
      </el-table-column>
      <el-table-column align="center" label="总分">
        <template slot-scope="scope">
          {{scope.row.总分}}
        </template>
      </el-table-column>
    </el-table>
</div>
</template>
<script>
  import request from '@/utils/request'
  import {loadCollege} from '@/api/college_score'
  import linq from 'linq';
  import NavBar from "../../components/NavBar/navBar";

  export default {
     components: {
    NavBar
  },
    data() {
      return {
        teachername:null,
        list: [],
        items: [],
        detailModel:null,
        showEdit:false,
        deps: [
        "计算机工程技术学院（人工智能学院）",

        "建筑工程学院",
     
        "艺术设计学院",
        "财会与金融学院",
        "机器人学院",
        "机械与汽车学院",
        "商学院",
        "体育健康学院",
        "应用外语学院",
        "旅游学院",
        "文化与传媒学院"
        ],
        scoreList: [],
        dlgVisible: false,
        selectDep: null,
        年份: '2019',
        listLoading: false,
      }
    },
    created() {
      //
      this.fetchData();
      //
    },
    methods: {
     
      
      async fetchData() {
        //

        //let teacher = getUser();
        this.listLoading = true;
        var datas = [];
         if( this.$root.user.role.indexOf("校领导") !== -1 ||
             this.$root.user.role.indexOf("人事处") !== -1
        ){
             datas = await  Promise.all(this.deps.map(async (item)=>{
              let res =   await loadCollege(item,this.年份)
              return res;
              }))
        }else if(this.deps.indexOf(this.$root.user.教师所属系部) !==-1)
        {
             let res =   await loadCollege(this.$root.user.教师所属系部,this.年份);
             datas.push(res);
        }
        this.list = linq.from(datas).orderByDescending("$.总分").toArray();
        this.listLoading = false;
        //
        //
      }
    }
  }
</script>
<style>
</style>